{
cairo_pattern_t *pattern;
cairo_matrix_t matrix;
- GtkAllocation allocation, border_allocation;
+ GtkAllocation border_allocation;
GskRoundedRect content_box;
- gtk_widget_get_allocation (widget, &allocation);
- /* TODO: This should be the border allocation */
- gtk_widget_get_allocation (widget, &border_allocation);
-
- border_allocation.x -= allocation.x;
- border_allocation.y -= allocation.y;
+ gtk_widget_get_border_allocation (widget, &border_allocation);
gtk_rounded_boxes_init_for_style (NULL,
NULL,
&content_box,
gtk_style_context_lookup_style (context),
- border_allocation.x,
- border_allocation.y,
+ 0, 0,
border_allocation.width,
border_allocation.height);
gtk_snapshot_push_rounded_clip (snapshot,
#include "gtkprivate.h"
#include "gtksnapshot.h"
#include "gtkstylecontext.h"
+#include "gtkwidgetprivate.h"
typedef struct _GtkDrawingAreaPrivate GtkDrawingAreaPrivate;
GtkDrawingArea *self = GTK_DRAWING_AREA (widget);
GtkDrawingAreaPrivate *priv = gtk_drawing_area_get_instance_private (self);
cairo_t *cr;
+ int width, height;
if (!priv->draw_func)
return;
+ gtk_widget_get_content_size (widget, &width, &height);
+
cr = gtk_snapshot_append_cairo (snapshot,
&GRAPHENE_RECT_INIT (
0, 0,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget)
+ width, height
),
"DrawingAreaContents");
priv->draw_func (self,
cr,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget),
+ width, height,
priv->draw_func_target);
cairo_destroy (cr);
}
#include "gtkprivate.h"
#include "gtkwindowprivate.h"
+#include "gtkwidgetprivate.h"
#include <string.h>
if (!completion->priv->filter_model)
return;
- gtk_widget_get_allocation (completion->priv->entry, &allocation);
+ gtk_widget_get_window_allocation (completion->priv->entry, &allocation);
gtk_widget_get_preferred_size (completion->priv->entry,
&entry_req, NULL);
GtkIconViewDropPosition dest_pos;
GtkIconViewItem *dest_item = NULL;
GtkStyleContext *context;
+ int width, height;
icon_view = GTK_ICON_VIEW (widget);
context = gtk_widget_get_style_context (widget);
+ gtk_widget_get_content_size (widget, &width, &height);
gtk_snapshot_push_clip (snapshot,
&GRAPHENE_RECT_INIT (
0, 0,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget)
+ width, height
),
"IconView Clip");
gtk_icon_view_motion (GtkWidget *widget,
GdkEventMotion *event)
{
- GtkAllocation allocation;
GtkIconView *icon_view;
gint abs_y;
if (icon_view->priv->doing_rubberband)
{
+ int width, height;
gtk_icon_view_update_rubberband (icon_view);
abs_y = event->y - icon_view->priv->height *
(gtk_adjustment_get_upper (icon_view->priv->vadjustment) -
gtk_adjustment_get_lower (icon_view->priv->vadjustment)));
- gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_content_size (widget, &width, &height);
- if (abs_y < 0 || abs_y > allocation.height)
+ if (abs_y < 0 || abs_y > height)
{
if (abs_y < 0)
icon_view->priv->scroll_value_diff = abs_y;
else
- icon_view->priv->scroll_value_diff = abs_y - allocation.height;
+ icon_view->priv->scroll_value_diff = abs_y - height;
icon_view->priv->event_last_x = event->x;
icon_view->priv->event_last_y = event->y;
static void
gtk_icon_view_set_hadjustment_values (GtkIconView *icon_view)
{
- GtkAllocation allocation;
+ int width, height;
GtkAdjustment *adj = icon_view->priv->hadjustment;
gdouble old_page_size;
gdouble old_upper;
gdouble new_value;
gdouble new_upper;
- gtk_widget_get_allocation (GTK_WIDGET (icon_view), &allocation);
+ gtk_widget_get_content_size (GTK_WIDGET (icon_view), &width, &height);
old_value = gtk_adjustment_get_value (adj);
old_upper = gtk_adjustment_get_upper (adj);
old_page_size = gtk_adjustment_get_page_size (adj);
- new_upper = MAX (allocation.width, icon_view->priv->width);
+ new_upper = MAX (width, icon_view->priv->width);
if (gtk_widget_get_direction (GTK_WIDGET (icon_view)) == GTK_TEXT_DIR_RTL)
{
* rectangle fixed. This means right edge of thumb should remain fixed.
* In this case, upper - value - page_size should remain constant.
*/
- new_value = (new_upper - allocation.width) -
+ new_value = (new_upper - width) -
(old_upper - old_value - old_page_size);
- new_value = CLAMP (new_value, 0, new_upper - allocation.width);
+ new_value = CLAMP (new_value, 0, new_upper - width);
}
else
- new_value = CLAMP (old_value, 0, new_upper - allocation.width);
+ new_value = CLAMP (old_value, 0, new_upper - width);
gtk_adjustment_configure (adj,
new_value,
0.0,
new_upper,
- allocation.width * 0.1,
- allocation.width * 0.9,
- allocation.width);
+ width * 0.1,
+ width * 0.9,
+ width);
}
static void
gtk_icon_view_set_vadjustment_values (GtkIconView *icon_view)
{
- GtkAllocation allocation;
+ int width, height;
GtkAdjustment *adj = icon_view->priv->vadjustment;
- gtk_widget_get_allocation (GTK_WIDGET (icon_view), &allocation);
+ gtk_widget_get_content_size (GTK_WIDGET (icon_view), &width, &height);
gtk_adjustment_configure (adj,
gtk_adjustment_get_value (adj),
0.0,
- MAX (allocation.height, icon_view->priv->height),
- allocation.height * 0.1,
- allocation.height * 0.9,
- allocation.height);
+ MAX (height, icon_view->priv->height),
+ height * 0.1,
+ height * 0.9,
+ height);
}
static void
gint col, row;
GtkRequestedSize *sizes;
gboolean rtl;
+ int width, height;
if (gtk_icon_view_is_empty (icon_view))
return;
rtl = gtk_widget_get_direction (GTK_WIDGET (icon_view)) == GTK_TEXT_DIR_RTL;
n_items = gtk_icon_view_get_n_items (icon_view);
+ gtk_widget_get_content_size (widget, &width, &height);
+
gtk_icon_view_compute_n_items_for_size (icon_view,
GTK_ORIENTATION_HORIZONTAL,
- gtk_widget_get_allocated_width (widget),
+ width,
NULL, NULL,
&n_columns, &item_width);
n_rows = (n_items + n_columns - 1) / n_columns;
priv->width = n_columns * (item_width + 2 * priv->item_padding + priv->column_spacing) - priv->column_spacing;
priv->width += 2 * priv->margin;
- priv->width = MAX (priv->width, gtk_widget_get_allocated_width (widget));
+ priv->width = MAX (priv->width, width);
/* Clear the per row contexts */
g_ptr_array_set_size (icon_view->priv->row_contexts, 0);
priv->height -= priv->row_spacing;
priv->height += priv->margin;
- priv->height = MIN (priv->height, gtk_widget_get_allocated_height (widget));
+ priv->height = MIN (priv->height, height);
- gtk_distribute_natural_allocation (gtk_widget_get_allocated_height (widget) - priv->height,
+ gtk_distribute_natural_allocation (height - priv->height,
n_rows,
sizes);
priv->height -= priv->row_spacing;
priv->height += priv->margin;
- priv->height = MAX (priv->height, gtk_widget_get_allocated_height (widget));
+ priv->height = MAX (priv->height, height);
}
static void
gtk_icon_view_queue_draw_item (GtkIconView *icon_view,
GtkIconViewItem *item)
{
- GdkRectangle rect;
- GdkRectangle *item_area = &item->cell_area;
- GtkAllocation allocation;
-
- rect.x = item_area->x - icon_view->priv->item_padding;
- rect.y = item_area->y - icon_view->priv->item_padding;
- rect.width = item_area->width + icon_view->priv->item_padding * 2;
- rect.height = item_area->height + icon_view->priv->item_padding * 2;
-
- gtk_widget_get_allocation (GTK_WIDGET (icon_view), &allocation);
-
- rect.x += allocation.x -
- gtk_adjustment_get_value (icon_view->priv->hadjustment);
- rect.y += allocation.y -
- gtk_adjustment_get_value (icon_view->priv->vadjustment);
-
- gtk_widget_queue_draw_area (GTK_WIDGET (icon_view), rect.x, rect.y, rect.width, rect.height);
+ gtk_widget_queue_draw (GTK_WIDGET (icon_view));
}
void
if (use_align)
{
- GtkAllocation allocation;
+ int width, height;
gint x, y;
gfloat offset;
GdkRectangle item_area =
x =0;
y =0;
- gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_content_size (widget, &width, &height);
- offset = y + item_area.y - row_align * (allocation.height - item_area.height);
+ offset = y + item_area.y - row_align * (height - item_area.height);
gtk_adjustment_set_value (icon_view->priv->vadjustment,
gtk_adjustment_get_value (icon_view->priv->vadjustment) + offset);
- offset = x + item_area.x - col_align * (allocation.width - item_area.width);
+ offset = x + item_area.x - col_align * (width - item_area.width);
gtk_adjustment_set_value (icon_view->priv->hadjustment,
gtk_adjustment_get_value (icon_view->priv->hadjustment) + offset);
static void
gtk_icon_view_autoscroll (GtkIconView *icon_view)
{
- GtkAllocation allocation;
gint px, py, width, height;
gint hoffset, voffset;
- gtk_widget_get_allocation (GTK_WIDGET (icon_view), &allocation);
px = icon_view->priv->event_last_x;
py = icon_view->priv->event_last_y;
- width = allocation.width;
- height = allocation.height;
+
+ gtk_widget_get_content_size (GTK_WIDGET (icon_view), &width, &height);
/* see if we are near the edge. */
voffset = py - 2 * SCROLL_EDGE_SIZE;
if (!priv->adjustment)
return;
- gtk_widget_get_allocation (GTK_WIDGET (row), &allocation);
+ gtk_widget_get_outer_allocation (GTK_WIDGET (row), &allocation);
y = allocation.y;
height = allocation.height;
header = ROW_PRIV (row)->header;
if (GTK_IS_WIDGET (header) && gtk_widget_is_drawable (header))
{
- gtk_widget_get_allocation (header, &allocation);
+ gtk_widget_get_outer_allocation (header, &allocation);
y = allocation.y;
height += allocation.height;
}
static void
gtk_menu_realize (GtkWidget *widget)
{
- GtkMenu *menu = GTK_MENU (widget);
- GtkAllocation allocation;
- GtkBorder arrow_border;
-
GTK_WIDGET_CLASS (gtk_menu_parent_class)->realize (widget);
- gtk_widget_get_allocation (widget, &allocation);
- get_arrows_border (menu, &arrow_border);
-
if (GTK_MENU_SHELL (widget)->priv->active_menu_item)
gtk_menu_scroll_item_visible (GTK_MENU_SHELL (widget),
GTK_MENU_SHELL (widget)->priv->active_menu_item);
GtkAllocation allocation;
int w, h;
- gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_outer_allocation (widget, &allocation);
w = allocation.width;
h = allocation.height;
GtkWidget *widget = gtk_widget_get_parent (GTK_WIDGET (gizmo));
GtkRange *range = GTK_RANGE (widget);
GtkRangePrivate *priv = range->priv;
- GtkAllocation slider_alloc, widget_alloc;
- GtkAllocation trough_alloc;
+ GtkAllocation slider_alloc;
double value;
/* Slider */
gtk_range_calc_marks (range);
- gtk_widget_get_allocation (widget, &widget_alloc);
- gtk_widget_get_allocation (GTK_WIDGET (gizmo), &trough_alloc);
gtk_range_compute_slider_position (range,
gtk_adjustment_get_value (priv->adjustment),
&slider_alloc);
if (range->priv->zoom)
{
- GtkAllocation allocation;
+ int width, height;
gint size, pos;
- gtk_widget_get_allocation (GTK_WIDGET (range), &allocation);
+ gtk_widget_get_content_size (GTK_WIDGET (range), &width, &height);
if (range->priv->orientation == GTK_ORIENTATION_VERTICAL)
{
- size = allocation.height;
+ size = height;
pos = range->priv->mouse_y;
}
else
{
- size = allocation.width;
+ size = width;
pos = range->priv->mouse_x;
}
gint *marks,
GtkPositionType pos)
{
- GtkAllocation allocation;
GSList *m;
gint i;
+ int width, height;
for (m = list->next, i = 1; m; m = m->next, i++)
{
return marks[i];
}
- gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_content_size (widget, &width, &height);
if (gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)) == GTK_ORIENTATION_HORIZONTAL)
- return allocation.width;
+ return width;
else
- return allocation.height;
+ return height;
}
static void
priv = sw->priv;
- gtk_widget_get_allocation (indicator->scrollbar, &indicator_alloc);
+ gtk_widget_get_outer_allocation (indicator->scrollbar, &indicator_alloc);
gdk_event_get_coords (event, &x, &y);
if (indicator->over)
GtkScrolledWindowPrivate *priv = scrolled_window->priv;
GtkBin *bin;
GtkAllocation child_allocation;
- GtkAllocation sw_allocation;
GtkWidget *child;
gint sb_width;
gint sb_height;
bin = GTK_BIN (scrolled_window);
- gtk_widget_get_allocation (GTK_WIDGET (scrolled_window), &sw_allocation);
-
/* Get possible scrollbar dimensions */
gtk_widget_measure (priv->vscrollbar, GTK_ORIENTATION_HORIZONTAL, -1,
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
GtkScrolledWindowPrivate *priv = scrolled_window->priv;
- GtkAllocation allocation;
-
- gtk_widget_get_allocation (widget, &allocation);
priv->hindicator.scrollbar = priv->hscrollbar;
priv->vindicator.scrollbar = priv->vscrollbar;
{
GtkStack *stack = GTK_STACK (widget);
GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
- GtkAllocation allocation;
+ int widget_width, widget_height;
gint x, y, width, height, pos_x, pos_y;
- gtk_widget_get_allocation (widget, &allocation);
+
+ gtk_widget_get_content_size (widget, &widget_width, &widget_height);
x = y = 0;
- width = allocation.width;
- height = allocation.height;
pos_x = pos_y = 0;
switch (priv->active_transition_type)
{
case GTK_STACK_TRANSITION_TYPE_UNDER_DOWN:
y = 0;
- height = allocation.height * (gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
+ height = widget_height * (gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
pos_y = height;
break;
case GTK_STACK_TRANSITION_TYPE_UNDER_UP:
- y = allocation.height * (1 - gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
- height = allocation.height - y;
- pos_y = y - allocation.height;
+ y = widget_height * (1 - gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
+ height = widget_height - y;
+ pos_y = y - widget_height;
break;
case GTK_STACK_TRANSITION_TYPE_UNDER_LEFT:
- x = allocation.width * (1 - gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
- width = allocation.width - x;
- pos_x = x - allocation.width;
+ x = widget_width * (1 - gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
+ width = widget_width - x;
+ pos_x = x - widget_width;
break;
case GTK_STACK_TRANSITION_TYPE_UNDER_RIGHT:
x = 0;
- width = allocation.width * (gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
+ width = widget_width * (gtk_progress_tracker_get_ease_out_cubic (&priv->tracker, FALSE));
pos_x = width;
break;
default:
if (priv->last_visible_node)
{
- GtkAllocation allocation;
graphene_matrix_t matrix;
int x, y;
+ int width, height;
- gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_content_size (widget, &width, &height);
x = get_bin_window_x (stack);
y = get_bin_window_y (stack);
switch (priv->active_transition_type)
{
case GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT:
- x -= allocation.width;
+ x -= width;
break;
case GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT:
- x += allocation.width;
+ x += width;
break;
case GTK_STACK_TRANSITION_TYPE_SLIDE_UP:
- y -= allocation.height;
+ y -= height;
break;
case GTK_STACK_TRANSITION_TYPE_SLIDE_DOWN:
- y += allocation.height;
+ y += height;
break;
case GTK_STACK_TRANSITION_TYPE_OVER_UP:
case GTK_STACK_TRANSITION_TYPE_OVER_DOWN:
}
if (gtk_widget_get_valign (priv->last_visible_child->widget) == GTK_ALIGN_END &&
- priv->last_visible_widget_height > allocation.height)
- y -= priv->last_visible_widget_height - allocation.height;
+ priv->last_visible_widget_height > height)
+ y -= priv->last_visible_widget_height - height;
else if (gtk_widget_get_valign (priv->last_visible_child->widget) == GTK_ALIGN_CENTER)
- y -= (priv->last_visible_widget_height - allocation.height) / 2;
+ y -= (priv->last_visible_widget_height - height) / 2;
graphene_matrix_init_translate (&matrix, &GRAPHENE_POINT3D_INIT (x, y, 0));
gtk_snapshot_push_transform (snapshot, &matrix, "StackSlide");
{
if (gtk_progress_tracker_get_state (&priv->tracker) != GTK_PROGRESS_STATE_AFTER)
{
+ int width, height;
+
if (priv->last_visible_node == NULL &&
priv->last_visible_child != NULL)
{
priv->last_visible_node = gtk_snapshot_finish (&last_visible_snapshot);
}
+ gtk_widget_get_content_size (widget, &width, &height);
gtk_snapshot_push_clip (snapshot,
&GRAPHENE_RECT_INIT(
0, 0,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget)
+ width, height
),
"StackAnimationClip");
#include "gtkorientable.h"
#include "gtkprivate.h"
#include "gtkintl.h"
+#include "gtkwidgetprivate.h"
/**
* SECTION:gtkstackswitcher
{
GtkStackSwitcher *self = GTK_STACK_SWITCHER (widget);
GtkStackSwitcherPrivate *priv;
- GtkAllocation allocation;
GtkWidget *button;
GHashTableIter iter;
gpointer value;
gboolean retval = FALSE;
- gtk_widget_get_allocation (widget, &allocation);
-
priv = gtk_stack_switcher_get_instance_private (self);
- x += allocation.x;
- y += allocation.y;
-
button = NULL;
g_hash_table_iter_init (&iter, priv->buttons);
while (g_hash_table_iter_next (&iter, NULL, &value))
{
- gtk_widget_get_allocation (GTK_WIDGET (value), &allocation);
- if (x >= allocation.x && x <= allocation.x + allocation.width &&
- y >= allocation.y && y <= allocation.y + allocation.height)
+ GdkRectangle allocation;
+
+ gtk_widget_get_outer_allocation (GTK_WIDGET (value), &allocation);
+ if (gdk_rectangle_contains_point (&allocation, (int)x, (int)y))
{
button = GTK_WIDGET (value);
retval = TRUE;